<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/24
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="AddTypeServlet" method="post">
    类别：<input type="text" name="type" id="type"><span id="msg" style="color: red"></span><br>
    <input type="submit" id="sub" value="提交" disabled="disabled">

</form>
<script>
    $(function () {
        $("#type").blur(function () {
            if ($("#type").val()!="") {
                $.get(
                    "AddLookTypeServlet",
                    {name:$("#type").val()},
                    function (data) {
                        if(data=="true" ){
                            $("#msg").html("该类型已存在").css("color","red");
                            $("#sub").attr("disabled","disabled");
                        }else {
                            $("#msg").html("可以录入").css("color","green");
                            $("#sub").attr("disabled",false);
                        }
                    }
                )
            }else {
                $("#msg").html("类型名不能为空").css("color","red");
                $("#sub").attr("disabled","disabled");
            }

        })
    })
</script>
</body>
</html>
